package com.koron.order.concession.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.concession.bean.po.ConcessionInfluencePo;
import com.koron.order.concession.service.ConcessionInfluenceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 让步接收单-影响对应从表(ConcessionInfluence)表控制层
 *
 * @author zhouj
 * @since 2022-01-14 10:14:08
 */
@Api(tags = "让步接收单-影响对应从表(ConcessionInfluence)")
@RestController
@RequestMapping("/concessionInfluence/")
public class ConcessionInfluenceController {

    @Autowired
    private ConcessionInfluenceService concessionInfluenceService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改让步接收单-影响对应从表")
    @PostMapping("insertOrUpdate")
    public Response<String> insertOrUpdate(@RequestBody ConcessionInfluencePo concessionInfluence) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), concessionInfluenceService, "insertOrUpdate", String.class, concessionInfluence));
    }

    @ApiOperation(value = "新增让步接收单-影响对应从表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody ConcessionInfluencePo concessionInfluence) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), concessionInfluenceService, "insert", Integer.class, concessionInfluence));
    }

    @ApiOperation(value = "批量新增让步接收单-影响对应从表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<ConcessionInfluencePo> concessionInfluenceList) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), concessionInfluenceService, "insertBatch", Integer.class, concessionInfluenceList));
    }

    @ApiOperation(value = "根据id更新让步接收单-影响对应从表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody ConcessionInfluencePo concessionInfluence) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), concessionInfluenceService, "update", Integer.class, concessionInfluence));
    }

    @ApiOperation(value = "根据id删除让步接收单-影响对应从表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), concessionInfluenceService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询让步接收单-影响对应从表")
    @GetMapping("queryById")
    public Response<ConcessionInfluencePo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), concessionInfluenceService, "queryById", ConcessionInfluencePo.class, id));
    }

    @ApiOperation(value = "不分页查询让步接收单-影响对应从表列表")
    @GetMapping("queryList")
    public Response<List<ConcessionInfluencePo>> queryList(ConcessionInfluencePo queryVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), concessionInfluenceService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询让步接收单-影响对应从表列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(ConcessionInfluencePo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), concessionInfluenceService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

}
